package library.common.view.popwindow;

import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.PopupWindow;

/**
 * unfinished
 *
 * @author Created by qiang.hou on 2018/12/27.
 * @version 1.0
 */
public class BasePopupWindow extends PopupWindow {
    public BasePopupWindow(Context context) {
        super(context);
        init(context);
    }

    public BasePopupWindow(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public BasePopupWindow(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    public BasePopupWindow(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
        init(context);
    }

    public BasePopupWindow(View contentView) {
        super(contentView);
        if (null != contentView && contentView.getContext() != null) {
            init(contentView.getContext());
        }
    }

    public BasePopupWindow(View contentView, int width, int height) {
        super(contentView, width, height);
        if (null != contentView && contentView.getContext() != null) {
            init(contentView.getContext());
        }
    }

    public BasePopupWindow(View contentView, int width, int height, boolean focusable) {
        super(contentView, width, height, focusable);
        if (null != contentView && contentView.getContext() != null) {
            init(contentView.getContext());
        }
    }

    private void init(Context context) {
        setFocusable(true);
        setOutsideTouchable(true);
        setBackgroundDrawable(new ColorDrawable());
    }
}
